//
//  AppGoodsListController.m
//  gungunchou
//
//  Created by lyzbmacos3 on 2018/12/4.
//  Copyright © 2018年 xskj. All rights reserved.
//

#import "AppGoodsListController.h"
#import "AppGoodsListUnitController.h"
#import "CatIdModel.h"

@interface AppGoodsListController ()
@property (weak, nonatomic) IBOutlet UIView *topView;
@property (nonatomic, copy) NSArray *controllerArr;
@end

@implementation AppGoodsListController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.controllerArr = NSArray.new;
    [self fetchCatIds];
    
//    self.segmentControl.frame = CGRectMake(0, 40, [UIScreen mainScreen].bounds.size.width, 44);
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}


- (void)fetchCatIds
{
    [MBProgressHUD showHUDAddedTo:KWindow animated:YES];
    [[CGNetManage shared] httpGetCateListWithCompleted:^(NSArray *data) {
        [MBProgressHUD hideHUDForView:KWindow animated:YES];
        if (data && data.count > 0) {

            NSMutableArray *tempMArr = NSMutableArray.new;
            for (NSDictionary *dic in data) {
                CatIdModel *model = [CatIdModel mj_objectWithKeyValues:dic];
                AppGoodsListUnitController *con = AppGoodsListUnitController.new;
                con.model = model;
                con.title = model.CateName;
                [tempMArr addObject:con];
            }
            self.controllerArr = [NSArray arrayWithArray:tempMArr];
            self.viewControllers = self.controllerArr;
            
        }
    } fail:^(NSError *err) {
        [MBProgressHUD hideHUDForView:KWindow animated:YES];
        
    }];
}



- (IBAction)cateClick:(id)sender {
    
}

- (IBAction)carClick:(id)sender {
    
}

@end
